﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Tencent.OA.ACM.Entity.RouteInfo>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>ViewEmpList</title>
    <link href="<%= this.Url.Content("~/content/Global.css") %>" rel="Stylesheet" type="text/css" />
    <link href="<%= this.Url.Content("~/content/Site.css") %>" rel="Stylesheet" type="text/css" />
    <link href="<%= this.Url.Content("~/content/jquery.fmext.css") %>" rel="stylesheet"
        type="text/css" />

    <script type="text/javascript" language="javascript" src="<%=this.Url.Content("~/content/scripts/jquery-1.4.2.js") %>"></script>

    <script type="text/javascript" language="javascript" src="<%=this.Url.Content("~/content/default.js") %>"></script>

    <script type="text/javascript" language="javascript" src="<%=this.Url.Content("~/content/Scripts/jquery.fmext.js") %>"></script>

</head>
<body style="width: 676px;">
    <div>
        <div id="dv_emplist_frame" class="dv_emplist_frame" style="height: 243px;">
            <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td style="vertical-align:top; width:120px;">
                        时间间隔：
                    </td>
                    <td>
                        <%=Html.TextBox("daySpan",DateTime.Today.AddDays(-30).ToString("yyyy-MM-dd"), new { @class = "form_text dateinput", style = "width:150px;" })%>
                        &nbsp; &nbsp; &nbsp;至今天
                         <div style=" color:#999;">发送短信给该日期至今天之内乘坐该路线的员工。</div>
                    </td>
                </tr>
                <tr>
                    <td style="width: 230px; vertical-align: top;">
                        通知内容：
                    </td>
                    <td>
                        <textarea rows="8" id="ta_content" onpropertychange="refreshCharsNumber()" oninput="refreshCharsNumber()"
                            cols="10" onkeypress="return limitinput(event);" maxlength="300" class="setting_field"
                            style="width: 360px; text-align: left;"><%=this.Model.RouteName %></textarea>                           
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td style="color: Gray;">
                        已输入&nbsp;&nbsp;<span id="sp_charsNumber" style="color: Red; font-weight: bold;">0</span>&nbsp;&nbsp;个字。
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        <input id="btn_sendNotice" type="button" value="发送通知" style="width: 80px;" class="form_bot"
                            onclick="checkFormat();" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
</body>

<script type="text/javascript" language="javascript">
    // 全局根路径
    var dircache = '<%=this.Url.Content("~/caches/") %>';
    var rid = '<%=ViewData["rid"] %>';
    $(function() {
        refreshCharsNumber();
    });

    function refreshCharsNumber() {
        var contents = $("#ta_content").val();
        if (contents.length > 300)
        {
            $("#ta_content").val(contents.substring(0,300));  
           }
           $("#sp_charsNumber").html($("#ta_content").val().length);
    }
    function limitinput(obj) {
        var contents = $("#ta_content").val();
        return contents.length < 300;
    }
    function checkFormat() {
        if (trim($("#ta_content").val()).length == 0 || $("#daySpan").val().length == 0) {
            alert("通知内容或时间间隔不能为空！");
            return false;
        }
        if (compareDate($("#daySpan").val(), '<%=DateTime.Today.ToShortDateString() %>'))
        {
            alert("时间间隔不能大于今天！");
            return false;
        }

        if (!confirm("该操作可能需要较长时间，在此期间请不要关闭窗口，\r\n是否继续？")) {
            return false;
        }        
        $("#btn_sendNotice").val("正在发送...");
        $("#btn_sendNotice").attr("disabled", "disabled");
        var url = '<%=this.Url.Content("~/Home/SendNotice") %>';
        var content = { "dt": $("#daySpan").val(), "content": $("#ta_content").val(), "routeId": rid };
        $.post(url, content, function(response) {
            if (response.StatuCode == -1) {
                window.parent.InfoTip.showMessage("通知发送失败，请重试！<br/>错误信息：" + response.Error, 2, 6000);
                $("#btn_sendNotice").attr("disabled", "");
                $("#btn_sendNotice").val("发送通知");
                window.parent.showModel();
            }
            else {
                window.parent.InfoTip.showMessage("通知发送成功！", 1);
                window.parent.showModel();
            }
        }, "json");
    }
</script>

</html>
